<template>
  <div class="type-body">
    <div class="title">分类</div>
    <div class="count">共计 {{ typeList.length }} 个分类</div>
    <div class="type-list" v-for="(item, i) in typeList" :key="i">
      <div class="type-item" @click="toTypeBlog(item.typeId)">
        {{ item.typeName }} ({{ item.typeBlogCount }})
      </div>
    </div>
  </div>
</template>

<script>
import { list } from "@/api/type";
export default {
  data() {
    return {
      typeList: [],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      list().then((res) => {
        this.typeList = res.data;
      });
    },
    // 条状到该分类的博客列表
    toTypeBlog(id) {
      this.$router.push("/typeblog/" + id);
    },
  },
};
</script>

<style src="./index.css" scoped>
</style>